<?php
class Admin_Model_Register extends Zend_Db_Table{
	protected $_name = 'register';
	protected $_primary = 'id';


	public function getAll($order="desc"){
		
		$db = Zend_Registry::get ( 'connectDb' );
		
		$select = $db->select ()->from ( array ('r' => 'register' ) )
			->join ( array ('p' => 'pages' ), 'p.id = r.course', array ('title' => 'p.title' ) );
		
		if ($order != "desc")
			$select = $select->order ( "r.time_register" );
		else
			$select = $select->order ( "r.time_register desc" );
		$stmt = $select->query ();
		$result = $stmt->fetchAll ();
		return $result;
		
	}
	public function updatePage($arrParam){
		$data=array('title'=>$arrParam['title'],
				'image'=>$arrParam['image'],
				'desription'=>$arrParam['description'],
				'category_id'=>$arrParam['category_id'],
				'content'=>$arrParam['content']);
		$where = 'id = ' . $arrParam['page_id'];
		$this->update($data, $where);
		
	}


	public function deletePage($arrParam = null){

			$where = 'page_id = ' . $arrParam['page_id'];
			$this->delete($where);
	
	}
	public function getRegister($arrParam ){
		$se = $this->select();
		$se->where("id= ?",$arrParam["id"]);
		$where = 'id = ' . $arrParam['id'];
		$data =array('status'=>"1");
		$this->update($data, $where);
		return $this->fetchRow($se)->toArray();
	
	}


}